﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COM.DTO;

namespace BUS
{
    public class AddressHandler
    {
        public static List<String> getAbsoluteAddress(string externalId)
        {
            List<String> returnList = new List<string>();
            string abAddr = "";
            List<Address> AddressList = new List<Address>();
            if (externalId.StartsWith(COM.CONST.PREFIX.HOTEL)) // Get Address of Hotel
            {
                Hotel Hotel = DAL.DAO.HotelDAO.GetHotelById(externalId);
                AddressList = Hotel.Address.ToList();
            }
            else if (externalId.StartsWith(COM.CONST.PREFIX.USER)) // Get Addres of User
            {
                User User = DAL.DAO.UserDAO.GetUserById(externalId);
                AddressList = User.Address.ToList();
            }
            else
            {
                AddressList = null;
            }

            if (AddressList != null)
            {
                for (int i = 0; i < AddressList.Count; i++)
                {
                    abAddr = "";
                    bool isNull = false;
                    Address addrTemp = AddressList.ElementAt(i);
                    while (!isNull)
                    {
                        abAddr += addrTemp.AddressName;
                        string parentId = addrTemp.AddressParentId;
                        if (parentId == null)
                        {
                            isNull = true;
                        }
                        else
                        {
                            addrTemp = DAL.DAO.AddressDAO.getAddressbyId(parentId);
                        }
                    }
                    returnList.Add(abAddr);
                }

            }
            return returnList;
        }

        public List<String> getListAddressByType(String addressTypeId)
        {
            List<String> returnList = new List<string>();



            return returnList;

        }
    }
}
